package cn.tedu.boot07.controller;

import cn.tedu.boot07.entity.Product;
import cn.tedu.boot07.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

@RestController
public class ProductController {

    @Autowired
    ProductMapper mapper;

    @RequestMapping("/insert")
    public int insert(@RequestBody Product product){
        mapper.insert(product);
        return 1;
    }

    @RequestMapping("/select")
    public List<Product> select(){
        return mapper.selelct();
    }

    @RequestMapping("/delete")
    /*public int delete(@RequestBody Product product){*/
    public int delete(int id){
        int n = mapper.deleteById(id);
        return n;
    }

    @RequestMapping("/selectById")
    public Product selectById(int id){
        return mapper.selelctById(id);
    }

    @RequestMapping("/update")
    public int update(@RequestBody Product product){
        return mapper.update(product);
    }
}
